import {patch} from './patch'

export function mountComponents(vm, el) {
  vm.$el = el

  Object.keys(vm.$options.data)
        .map(key => {
          Object.defineProperty(vm, key, {
            get() {
              return vm.$options.data[key]
            }
          })
        })

  vm._update(vm._render())
}

export function lifecycleMixin(Vue) {
  Vue.prototype._update = function (vnode) {
    const vm = this

    vm.$el = patch(vm.$el, vnode)
  }
}
